home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 4 / Apprentice-Release4.iso / Source Code / Libraries / C Internet Config / Examples ƒ / Example / IC Resource ƒ / Syslog Component ƒ / Test Component.c < prev   
Encoding:
C/C++ Source or Header  |  1995-11-15  |  1.9 KB  |  81 lines  |  [TEXT/SPM ]

  1. #include <stdio.h>
  2.  
  3. #include <Components.h>
  4.  
  5. #include "syslog.h"
  6.  
  7. #include <GestaltEqu.h>
  8. #include <Folders.h>
  9. #include <Processes.h>
  10.  
  11. #include <stdarg.h>
  12. #include <string.h>
  13.  
  14. void main(void){
  15.     OSErr err;
  16.     FSSpec spec;
  17.     long dirid;
  18.     short vref;
  19.     
  20.     printf("Syslog Component Test\n\n");
  21.     
  22.     if (HaveComponentMgr()){
  23.         printf("We have the component mgr\n");
  24.         
  25.         syslog(LOG_INFO,"Syslog Component Test Begin");
  26.         
  27.         printf("Finding the desktop folder\n");
  28.         
  29.         FindFolder(kOnSystemDisk,kDesktopFolderType,kCreateFolder,&vref,&dirid);
  30.         
  31.         FSMakeFSSpec(vref,dirid,
  32. #if defined(powerc)||defined(__powerc)
  33.             "\pPowerMac Syslog File"
  34. #else
  35.             "\p68K Syslog File"
  36. #endif
  37.             ,&spec);
  38.         
  39.         printf("Have an fsspec (vref %d, dirid %ld, name %#s), setting filespec\n",spec.vRefNum,
  40.             spec.parID,spec.name);
  41.         
  42.         // should have a spec, now set the instance up...
  43.         setsyslogfile(&spec);
  44.         
  45.         printf("Set the spec, opening the file\n");
  46.         
  47.         openlog("test",0,LOG_USER);
  48.         
  49.         printf("Writing info into the new log file");
  50.         
  51.         syslog(LOG_INFO,"2 plus 2 is %d",4);
  52.         
  53.         syslog(LOG_CRIT,"Critical Notification!");
  54.         
  55.         syslog(LOG_ERR,"Since this log is created using openlog, it is intialized every time");
  56.         syslog(LOG_ERR,"and will start at a known state.  The syslog file in the system folder");
  57.         syslog(LOG_ERR,"does not get reset, it will build up over time, just like the normal syslog");
  58.         syslog(LOG_ERR,"Well, really the unix syslog file is initialized at every restart.  I didn't think");
  59.         syslog(LOG_ERR,"that would be very practical for a mac implementation.  However, you can");
  60.         syslog(LOG_ERR,"initialize it programmatically by calling openlog right away without changing");
  61.         syslog(LOG_ERR,"the file first");
  62.         
  63.         syslog(LOG_DEBUG,"Test complete");
  64.         
  65.         printf("Writing completed, closing the log\n\n");
  66.         
  67.         closelog();
  68.         
  69.         printf("Log closed\n");
  70.         syslog(LOG_INFO,"Syslog Component Test Complete");
  71.         
  72.     } else {
  73.         printf("No Component Mgr!\n");
  74.     }
  75.     
  76.     fflush(stdout);
  77.     
  78.     return;
  79. }
  80.  
  81.